<?php
!defined('P_W') && exit('Forbidden');
InitGP(array('hid'),'GP',2);
InitGP(array('step'),'GP',1);
empty($hid) && adminmsg("请先选择楼盘");
include (D_P . 'data/bbscache/house_config.php');
$pw_housemapDB = House::loadDB('housemap');
$posthash = EncodeUrl("$basename&action=map", true);
if($step == 1){
	//获得楼盘信息
	$houseinfoDB = House::loadDB('HouseInfo');
	$houseinfo = $houseinfoDB->getListByIds(array($hid));
	if (is_array($houseinfo) && !empty($houseinfo)) {
		$sContent = $houseinfo[0];
		$sTitle = $houseinfo[0]['name'];
	}
	$mapinfo = $pw_housemapDB->queryHouseMapByHid($hid);
	
	//default map info
	$point_x = $point_y = 0;
	$mapZoom = 12;
	$pointLaber = $pointTitle = '';
	if (is_array($mapinfo) && !empty($mapinfo)) {
		$mapId = $mapinfo['id'];
		$point_x = $mapinfo['x'];
		$point_y = $mapinfo['y'];
		$mapZoom = $mapinfo['zoom'];
		$pointTitle = $mapinfo['name'];
	}
}elseif($step == 2){
	define('AJAX',1);
	InitGP(array('point_x','point_y','mapZoom'),'GP');
	if (empty($point_x) || empty($point_y)) {
		Showmsg('“坐标点”或者“Laber信息”不能为空！');
	}
	//获得楼盘信息
	$houseinfoDB = House::loadDB('HouseInfo');
	$houseinfo = $houseinfoDB->getListByIds(array($hid));
	if (is_array($houseinfo) && !empty($houseinfo)) {
		$sContent = $houseinfo[0];
		$sTitle = $houseinfo[0]['name'];
	}
//	$content = "<table width='260' style='line-height:1.8;color:#333;'>";
//	$content .= "<tr><th width='40'>电话: </th><td>$sContent[saletele] </td></tr>";
//	$content .= "<tr><th>均价: </th><td>$sContent[aveprice] </td></tr>";
//	$content .= "<tr><th valign='top'>地址: </th><td>$sContent[address] </td></tr>";
//	$content .= "<tr><td colspan='2' style='text-align:right;'><a style='color:#3366cc;' href='mode.php?m=house&q=info&hid=$sContent[hid]' target='_blank'>查看详情</a></td></tr>";
//	$content .= "</table>";
	(empty($mapZoom) || !is_numeric($mapZoom) || $mapZoom > 17 || $mapZoom < 3) && $mapZoom = 12;
//	$content = trim($content);
//	$content = str_replace(array("\0", "%00", "\r", "\n"), '', $content);
//	$content = Char_cv($content);
	
	$mapinfo = array('hid'		=> $hid,
					 'x'		=> $point_x,
					 'y'		=> $point_y,
				     'zoom'		=> $mapZoom
//					 'laber'	=> $content
	);
	$pw_housemapDB->replaceHouseMapById($mapinfo);
	Showmsg('operate_success'); ajax_footer();exit;
}
include PrintMode('housemap');
parsePageContent();
exit;
function parsePageContent(){
	$output = ob_get_contents();
	if ($db_htmifopen) {
		$output = preg_replace(
			"/\<a(\s*[^\>]+\s*)href\=([\"|\']?)((index|cate|thread|read|faq|rss)\.php\?[^\"\'>\s]+\s?)[\"|\']?/ies",
			"Htm_cv('\\3','<a\\1href=\"')",
			$output
		);
	}
	if ($db_redundancy && $SCR!='post') {
		$output = str_replace(
			array("\r",'<!---->-->','<!--<!---->',"<!---->\n",'<!---->','<!-- -->',"<!--\n-->","\t\t",'        ',"\n\t","\n\n"),
			array('','','','','','','','',"\n","\n"),
			$output
		);
	} else {
		$output = str_replace(array('<!---->-->','<!--<!---->',"<!---->\r\n",'<!---->','<!-- -->',"\t\t\t"),'',$output);
	}
//	updateCacheData();
	echo ObContents($output);
	unset($output);
	N_flush();
	exit;
}
?>